package com.fzj.example.design.iterator;

import java.util.ArrayList;
import java.util.List;

/**
* @Description
* @Author  fanzj
* @Date   2020/5/10 9:26 下午
* @Param  
* @Return      
* @Exception   
* 
*/
public class ConcreteIterator implements Iterator {

    private List<Object> objectList=null;
    private int index=-1;

    public ConcreteIterator(List<Object> objectList) {
        this.objectList = objectList;
    }

    @Override
    public Object first() {
        index=0;
        return objectList.get(index);
    }

    @Override
    public Object next() {
       if(this.hasNext()){
           return this.objectList.get(++index);
       }
       return null;
    }

    @Override
    public boolean hasNext() {
        if(index<objectList.size()-1){
            return true;
        }
        return false;
    }
}
